package test

import (
	"fmt"
	"youdu/config"
	"youdu/service/ipa"
	"youdu/service/yodoo"
)

func IpaLogin() {
	// 测试登录
	username := "dengwei"
	password := "xinda456"
	err := ipa.LoginFreeIPA(username, password)
	if err != nil {
		fmt.Println("Error:", err)
	} else {
		fmt.Println("Login successful")
	}
}

func Aes() {
	// {\"fromUser\":\"dengwei\",\"createTime\":1348831860,\"packageId\":1234567890,\"msgType\":\"auth\",\"passwd\":\"xinda456\"}
	// HaKH6Zy+tW7A6r1gFcrYo+J8Qf2oK0Ja4CRZ8PLzqk7XgUTh0C6HNtUXu5uVyFyYc8V+fMoGcJEGgR2y7xGjuwdGwXSTmN0R7ZvyYLepQD7tFWXyG9lEfJYbUYg6f61JmxNTlA5zRAyyaz0i7xgHziJkV+16fwhNX6eo6Fhu0VnRNqOTeHyHzR/59cR2c5dA6sOgXs+Y6i9L7TlLi4ZeHQ==
	// 测试输出aes加密
	// {\"fromUser\":\"fakeacc\",\"createTime\":1348831860,\"packageId\":1234567890,\"msgType\":\"auth\",\"passwd\":\"123456\"}
	// 34tQ/IAjzHL1ik/m8bTw3U92uCiEDzjH9JLqppNd7Nrx/w3EqRBiH1Zs6p0GSe7WVjE/4d/bl1dFg5r/fMOR1xhs9RwEhOHfNIxPx4tLbzNFWKd0MO0WScnUoCX0MngvcAokfVKGmG6LidFlc9InuzsJO1AAdvTNMlBZqsc05V0IT0rZdYXVxP5vwlxjAd9oZT5Pur1hOTbcADm7E7yvew==
	miwen, err := yodoo.AesEncrypt([]byte("{\"fromUser\":\"dengwei\",\"createTime\":1348831860,\"packageId\":1234567890,\"msgType\":\"auth\",\"passwd\":\"xinda456\"}"), config.Inst.YouduApp.SysOrg.AesKey, config.Inst.YouduApp.SysOrg.AppId)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("密文：" + miwen)
	// 解密测试 miwen
	mingwen, err := (yodoo.AesDecrypt(miwen, config.Inst.YouduApp.SysOrg.AesKey))
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("明文：" + string(mingwen.Data))
}

func YDMsg() {
	// 测试输出aes解密
	en := "eFFE4mT1vvtOQSwABIHsKwZr5MrRL7XMreLjdBrAbScXNQsKDOJYNcrMFIAN+hx/vC6U6hT2qhm9y2XucZUKmt8BtxW52vMfJL6xKsb9IcPTAirvDoKaZ68te/xfwc/dLQ2kVZCf3is09CyOtOZ2mXRWjZFDYmhHqLRaPAZw9RbIkfXH3oAbBtwRHYqBLNUU6rZuxJ80TcepsTS5g29A/zvbUZRx99M5HJNZ0lz1orDQTeE3BN1BaOfyZCVCdiUQb0miRQM962rwhIrcJl928NtYfSk38s2W4nkUtJBws6Y="
	ydData, err := (yodoo.AesDecrypt(en, config.Inst.YouduApp.SysOrg.AesKey))
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("明文：" + ydData.AppId)
}
